package com.codeavatar.catools.lib.tester;

import java.util.ArrayList;
import java.util.List;

/**
 * +----------------------------------------------------------------------
 * | @Author: codeavatar   @Year：2022
 * +----------------------------------------------------------------------
 * | @Email: codeavatar@aliyun.com
 * +----------------------------------------------------------------------
 **/
public class CaReportLib {

    private final String LINE_SEPARATOR = System.getProperty("line.separator");

    private final String PREFIX = ":::";
    private final String BEGIN_SPLIT_LINE = PREFIX +
            "++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++";
    private final String END_SPLIT_LINE = PREFIX +
            "======================================================================================================";

    private List<StringBuilder> log = new ArrayList<>();
    private int logIndex = 0;

    //++++++++++++++++++++++++++++++++++++++
    //++ 外部方法
    //++++++++++++++++++++++++++++++++++++++

    public void start(){
        log.add(new StringBuilder(""));
        StringBuilder sb = log.get(logIndex);
        sb.append(BEGIN_SPLIT_LINE);
    }

    public void stop(){
        log.add(new StringBuilder(""));
        StringBuilder sb = log.get(logIndex);
        sb.append(LINE_SEPARATOR);
        sb.append(END_SPLIT_LINE);
    }

    public void log(String msg){
        StringBuilder sb = log.get(logIndex);
        sb.append(LINE_SEPARATOR);
        sb.append(PREFIX + msg);
    }

    public void asynchronized(){

    }

    //++++++++++++++++++++++++++++++++++++++
    //++ 内部方法
    //++++++++++++++++++++++++++++++++++++++

    private CaReportLib(){
        // Private constructor to prevent unwanted construction.
    }
}
